/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package spreadsheet.containers;

import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import spreadsheet.gui.JeksJMenuBar;
import spreadsheet.spreadsheet.Table.Spreadsheet;
import spreadsheet.storablespreadsheet.StorableDataFrame;

/**
 *
 * @author Nobody
 */
public class SpreadsheetWindow extends JFrame implements ISpreadsheetContainer {

    private JPanel panel;
    private SpreadsheetScrollpane scrollPane;
    private JeksJMenuBar menuBar;

    public SpreadsheetWindow() {
        scrollPane = new SpreadsheetScrollpane();
        initComponents();
    }

    public Spreadsheet getSpreadsheet() {
        return scrollPane.getSpreadsheet();
    }

    private void initComponents() {
        panel = new JPanel(new BorderLayout());
        panel.add(scrollPane, BorderLayout.CENTER);
        getContentPane().add(panel, BorderLayout.CENTER);
        panel.add(scrollPane.getFormulaField(), BorderLayout.NORTH);
        panel.updateUI();
        menuBar = new JeksJMenuBar(scrollPane.getSpreadsheet());
        setJMenuBar(menuBar);
        pack();

    }

    public StorableDataFrame exportAsStorableDataFrame() {
        return new StorableDataFrame(this);
    }

    public static void main(String[] args) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new SpreadsheetWindow().setVisible(true);
            }
        });
    }
}
